package vaadin.lab5;

import java.util.Arrays;

import com.vaadin.Application;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.TextField;
import com.vaadin.ui.Window;

@SuppressWarnings("serial")
public class Lab extends Application {

    @Override
    public void init() {
        FormLayout mainLayout = new FormLayout();
        mainLayout.setSpacing(true);
        mainLayout.setMargin(true);
        Window mainWindow = new Window("Lab", mainLayout);
        setMainWindow(mainWindow);

        ComboBox comboBox = new ComboBox("ComboBox", Arrays.asList("Item 1",
                "Item 2", "Item 3"));
        comboBox.setNewItemsAllowed(true);
        comboBox.setImmediate(true);

        TextField textField = new TextField("TextField");
        textField.setImmediate(true);

        TextField textField2 = new TextField("TextField", textField);
        textField2.setReadOnly(true);

        comboBox.setPropertyDataSource(textField);

        mainWindow.addComponent(comboBox);
        mainWindow.addComponent(textField);
        mainWindow.addComponent(textField2);
    }
}
